# Cache Stage
# Only rebuild layer if package.json has changed
FROM node:lts-alpine as node-cache
MAINTAINER thincats@163.com
WORKDIR /cache/
COPY package.json .
# Uncomment below if you're using .npmrc
# COPY .npmrc .
RUN npm prune 
RUN npm install

# build stage
FROM node:lts-alpine as build-stage
WORKDIR /app
COPY --from=node-cache /cache/ .
COPY . .

ARG VUE_APP_GRAPHQL_HTTP
ARG VUE_APP_GRAPHQL_WS
RUN npm run build

# production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
